package com.jhte.scheduleJob.service;

import com.jhte.scheduleJob.dao.QuartzLogDao;
import com.jhte.scheduleJob.entity.QuartzLog;
import com.jhte.scheduleJob.vo.QueQuartzLogRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * @author wuchun
 * @description
 * @create 2018-01-31 11:59
 */
@Service
@Transactional
public class QuartzLogServiceImpl implements QuartzLogService {

    @Autowired
    private QuartzLogDao quartzLogDao;

    /**
     * 查询定时任务日志列表
     *
     * @param queQuartzLogRequest
     * @return
     */
    @Override
    public Map<String, Object> queryQuartzLogList(QueQuartzLogRequest queQuartzLogRequest) {
        Map<String, Object> map = new LinkedHashMap<>();
        List<QuartzLog> quartzList = quartzLogDao.queryQuartzLogList(queQuartzLogRequest);
        int count = quartzLogDao.queryQuartzLogCount(queQuartzLogRequest);
        map.put("list", quartzList);
        map.put("count", count);
        return map;
    }

    /**
     * 添加任务执行日志
     *
     * @param quartzLog
     * @return
     */
    @Override
    public int insertQuartzLog(QuartzLog quartzLog) {
        int flag = 0;
        flag = quartzLogDao.insertQuartzLog(quartzLog);
        return flag;
    }

    /**
     * 修改任务执行日志
     *
     * @param quartzLog
     * @return
     */
    @Override
    public int updateQuartzLog(QuartzLog quartzLog) {
        int flag = 0;
        flag = quartzLogDao.updateQuartzLog(quartzLog);
        return flag;
    }
}
